# https://colab.research.google.com/drive/1ZLA4QufsiI_RuNlamKqV7D7mn40FbWoY?usp=sharing#scrollTo=wLB-BPGqGi2e


import objaverse
import multiprocessing
import random

def TestObjaverse():
    print(objaverse.__version__)
    uids=objaverse.load_uids()
    # print(len(uids))
    # print(type(uids))
    # print(uids[:10])

    # annotations=objaverse.load_annotations(uids[:10])
    # print(annotations)
    # print(annotations[uids[0]])

    annotations=objaverse.load_annotations()
    cc_by_uids = [uid for uid, annotation in annotations.items() if annotation["license"] == "by"]
    print(cc_by_uids[:10])

def TestCpu():

    processes = multiprocessing.cpu_count()
    print(processes)
    return  processes

def TestRandom():
    random.seed(42)
    uids=objaverse.load_uids()
    random_object_uids=random.sample(uids,100)
    print(random_object_uids)
    return random_object_uids

def TestRandomLoadObjects():
    processes=TestCpu()
    random_object_uids=TestRandom()
    objects=objaverse.load_objects(
        uids=random_object_uids,
        download_processes=processes
    )
    print(objects)



# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # TestObjaverse()
    # TestCpu()
    # TestRandom()
    TestRandomLoadObjects()
